<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <title>分单列表</title>
        <% include("/common/common_css_js.html"){} %>
        <script type="text/javascript" src="${base!}/js/LodopFuncs.js?d=${jdate!}"></script>

        <style>

            .tab1
            {
                border-collapse:collapse;
                border-color: black;
            }

            .border1
            {
                border:1px solid black;
            }

            .PageNext{page-break-after: always;}
        </style>

    </head>
    <body>
        <object style="display: none" id="LODOP" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
            <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0></embed>
        </object>
        <div style="padding-bottom: 5px;">
            <div id="queryForm" class="uc-toolbaroverflow" _borderStyle="border-top:0;">
                <span>分单号:</span><input id="keyBillCode" name="keyBillCode" emptyText="请输入分单号"  class="mini-textbox" selectOnFocus="true" required="false" requiredErrorText="分单号不能为空" />
                <span class="separator"></span>
                <span>分单归属部门:</span>
                <input id="keyAttributionDepartmentId" name="keyAttributionDepartmentId" class="mini-treeselect" style="width:400px;" textField="name" valueField="id" emptyText="请选择..."
                       expandOnLoad="2"  virtualScroll="true" multiSelect = "true"  showFolderCheckBox="true"
                       required="false" allowInput="true" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择归属部门"/>
                <span class="separator"></span>
                <span>运输种类:</span><input id="keyTransportSpeciesId" name="keyTransportSpeciesId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                                         required="false" allowInput="false" showNullItem="false" nullItemText="请选择..." requiredErrorText="没有选择运输种类" />
                <span class="separator"></span>
                <span>承运方式:</span><input id="keyTransportWayId" name="keyTransportWayId" class="mini-combobox" style="width:150px;" textField="name" valueField="id" emptyText="请选择..."
                                         required="false" allowInput="false" showNullItem="false" nullItemText="请选择..." requiredErrorText="没有选择承运方式"/>


                <div style="margin-top: 5px"></div>
                <span>物品名称:</span><input id="keyGoodsName" name="keyGoodsName" emptyText="请输入物品名称"  class="mini-textbox" selectOnFocus="true" required="false" requiredErrorText="物品名称不能为空" />

                <span class="separator"></span>
                <span>始发机场:</span>
                <div id="keyAirportId" name="keyAirportId" class="mini-combobox" style="width:300px;"  popupWidth="400" textField="name" valueField="id"
                     required="false" requiredErrorText="没有选择始发机场"
                     searchField="key"
                     allowInput="true"
                     emptyText="始发机场名称">
                    <div property="columns">
<!--                        <div header="ID" field="id" width="30"></div>-->
                        <div header="机场名称" field="name"></div>
                        <div header="简称" field="shortName"></div>
                    </div>
                </div>

                <span class="separator"></span>
                <span>目的市:</span><input id="keyDestCityId" name="keyDestCityId" class="mini-treeselect"
                                        emptyText="目的市"
                                        multiSelect="false" valueField="id" textField="name" parentField="pid" allowInput="true" valueFromSelect="true"  virtualScroll="true"
                                        style="width: 220px;" expandOnLoad="true" required="false" requiredErrorText="没有选择目的市" nullItemText="请选择..." />

                <span class="separator"></span>
                <span>班次号:</span><input id="keyFlightName" name="keyFlightName" emptyText="请输入班次号"  class="mini-textbox" selectOnFocus="true" required="false" requiredErrorText="班次号不能为空" />


                <div style="margin-top: 5px"></div>
                <span>发货人:</span>
                <div id="keyDeliveryCustomerId" name="keyDeliveryCustomerId" class="mini-autocomplete" style="width:250px;"  popupWidth="1000" textField="name" valueField="id"
                     url="${base}/pages/customer_manage/queryDeliveryCustomerByKey"  required="false" requiredErrorText="发货人不能为空"
                     searchField="key"
                     emptyText="发货人名称">
                    <div property="columns">
                        <div header="ID" field="id" width="30"></div>
                        <div header="客户名称" field="name"></div>
                        <div header="客户简称" field="shortName"></div>
                        <div header="客户电话" field="phone"></div>
                        <div header="客户地址" field="address"></div>
                    </div>
                </div>

                <span class="separator"></span>
                <span>收货人:</span>
                <input id="keyReceiveCustomerName" name="keyReceiveCustomerName" style="width:250px;"  emptyText="收货人名称"  class="mini-textbox" selectOnFocus="true" required="false" requiredErrorText="收货人名称不能为空"/>

                <span class="separator"></span>

                <span>提货点:</span>
                <div id="keyPickUpPointId" name="keyPickUpPointId" class="mini-autocomplete" style="width:300px;"  popupWidth="500" textField="name" valueField="id"
                     required="false" requiredErrorText="提货点不能为空"
                     url="${base}/pages/basic_data_manage/xt_pick_up_point/queryPickUpPointByCondition?cityId="
                     searchField="key"
                     emptyText="提货点名称">
                    <div property="columns">
                        <div header="提货点名称" field="name" width="150"></div>
                        <div header="提货点电话" field="phone" width="150"></div>
                        <div header="提货点地址" field="address" width="200"></div>
                    </div>
                </div>
                <span class="separator"></span>
                <span>提货方式:</span>
                <input id="keyPickUpGoodsWayId" name="keyPickUpGoodsWayId" class="mini-combobox" style="width:120px;" textField="name" valueField="id" emptyText="请选择..."
                                         required="false" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择提货方式"/>
                <span class="separator"></span>
                <span>签收方式:</span>
                <input id="keySignChooseId" name="keySignChooseId" class="mini-combobox" style="width:120px;" textField="name" valueField="id" emptyText="请选择..."
                                         required="false" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择签收方式"/>

                <div style="margin-top: 5px"></div>
                <span>开单日期:</span>
                <input id="keyOpenBillStartDate" name="keyOpenBillStartDate"  class="mini-datepicker"   format="yyyy-MM-dd"/>--<input id="keyOpenBillEndDate" name="keyOpenBillEndDate" class="mini-datepicker"  format="yyyy-MM-dd"/>
                <span class="separator"></span>
<!--                <span>收银员：</span>-->
                <div id="keyCashierId" name="keyCashierId" class="mini-autocomplete" style="width:300px;display: none"  popupWidth="300" textField="name" valueField="id"
                     required="false" requiredErrorText="收银员不能为空"
                     url="${base}/pages/cash_set_manage/queryCashierByCondition"
                     searchField="key"
                     emptyText="收银员姓名、电话">
                    <div property="columns">
                        <div header="姓名" field="name" width="150"></div>
                        <div header="电话" field="mobile" width="150"></div>
                    </div>
                </div>

<!--                <div style="margin-top: 5px"></div>-->
                <span>配载状态:</span>
                <input id="keyBillLoadStatusId" name="keyBillLoadStatusId" class="mini-combobox" style="width:120px;" textField="name" valueField="id" emptyText="请选择..."
                       required="false" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择配载状态"/>
                <span class="separator"></span>
                <span>拉货状态:</span>
                <input id="keyDropStatusId" name="keyDropStatusId" class="mini-combobox" style="width:120px;" textField="name" valueField="id" emptyText="请选择..."
                       required="false" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择拉货状态"/>
                <span class="separator"></span>
                <span>对账状态:</span>
                <input id="keyAccountCheckStatusId" name="keyAccountCheckStatusId" class="mini-combobox" style="width:120px;" textField="name" valueField="id" emptyText="请选择..."
                       required="false" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择对账状态"/>
                <span class="separator"></span>
                <span>结算状态:</span>
                <input id="keySettlementStatusId" name="keySettlementStatusId" class="mini-combobox" style="width:120px;" textField="name" valueField="id" emptyText="请选择..."
                       required="false" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择结算状态"/>
                <span class="separator"></span>
                <span>作废状态:</span>
                <input id="keyCancelStatusId" name="keyCancelStatusId" class="mini-combobox" style="width:120px;" textField="name" valueField="id" emptyText="请选择..."
                       required="false" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择作废状态"/>

                <div style="margin-top: 5px"></div>

                <% if(so.hasPermission("bNativeBill:query")){%>
                    <a class="mini-button" iconCls="icon-search" onclick="searchBill()">查询</a>
                <% } %>

                <% if(so.hasPermission("bNativeBill:queryCndClear")){%>
                    <a class="mini-button" iconCls="icon-new" onclick="clearSearch()">清空查询条件</a>
                <% } %>

                <span class="separator"></span>

                <% if(so.hasPermission("bNativeBill:edit")){%>
                    <a class="mini-button" iconCls="icon-edit" onclick="editBillShow()">编辑</a>
                <% } %>

                <% if(so.hasPermission("bNativeBill:invalid")){%>
                    <a class="mini-button" iconCls="icon-cancel" onclick="cancelBill()">作废</a>
                <% } %>

                <% if(so.hasPermission("bNativeBill:delete")){%>
                    <a class="mini-button" iconCls="icon-remove" onclick="deleteBill()">删除</a>
                <% } %>


                <% if(so.hasPermission("bNativeBill:fillPickupDriverFee")){%>
                    <span class="separator"></span>
                    <a class="mini-button" iconCls="icon-edit" onclick="showFillPickupDriverFee()">填写分单提货费</a>
                <% } %>

                <span class="separator"></span>

                <% if(so.hasPermission("bNativeBill:signStatusChange")){%>
                    <a class="mini-button"  onclick="showSignStatusPanel()">签收状态修改</a>
                <% } %>

                <% if(so.hasPermission("bNativeBill:dailyReportPrint")){%>
                    <a class="mini-button"  onclick="showDailyReportPrintPanel()">打印日报</a>
                <% } %>

                <% if(so.hasPermission("bNativeBill:download")){%>
                    <span class="separator"></span>
                    <#download_grid id="downloadGrid" theGridId="datagrid1" theFileName="分单信息表"/>
                <% } %>

            </div>
        </div>

        <div class = "mini-fit">
            <div id="datagrid1" class="mini-datagrid"
                 style="width: 100%; height: 100%;"
                 url="${base}/pages/native_bill_manage/queryBill" idField="id"
                 showPager="true" pageSize="20" sizeList="[10,20,30,50,100]"
                 multiSelect = "true" allowResize="true"
                 showGroupsSummary="true" showSummaryRow="true" summaryPosition="bottom"
                 allowSortColumn = "true"
                 sortField="createTime"
                 sortOrder="desc"
                 onshowrowdetail="onShowRowDetail"
                 ondrawsummarycell="summaryRight"
            >
                <div property="columns">
                    <div type="checkcolumn" ></div>
                    <div type="expandcolumn" ></div>
                    <div field="id" width="140" headerAlign="center" align="center" allowSort="true" renderer="showNativeBillRender" >分单号</div>
                    <div field="billLoadMasterBillIds" width="140" headerAlign="center" align="center" allowSort="true">主单号</div>
                    <div field="openBillDate" width="140" headerAlign="center" align="center" allowSort="false" dateFormat="yyyy-MM-dd HH:mm:ss" renderer="ondayRenderer">开单日期</div>
                    <div field="airportId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"airport"}' renderer="commonRender">始发机场</div>
                    <div field="destCityId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"city"}' renderer="commonRender">目的市</div>
                    <div field="goodsName" width="140" headerAlign="center" align="center" allowSort="true" >货物名称</div>
                    <div field="goodsTypeId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"sysDic"}' renderer="commonRender">货物类型</div>
                    <div field="packingWayId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"sysDic"}' renderer="commonRender">包装方式</div>

                    <div field="volumeInformation" width="140" headerAlign="center" align="center" allowSort="true">体积信息</div>
                    <div field="totalNumber" width="140" headerAlign="center" align="right" allowSort="false" summaryType="sum">总件数</div>
                    <div field="actualWeight" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">实际重量</div>
                    <div field="chargeableWeight" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">计费重量</div>
                    <div field="weightRate" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer">重量费率</div>
                    <div field="volume" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">体积</div>
                    <div field="volumeRate" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer">体积费率</div>
                    <div field="ticketPrice" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer"  summaryType="sum">起票价</div>
                    <div field="transportCost" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">运费合计</div>

                    <div field="declaredValue" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">声明价值</div>
                    <div field="insuranceRate" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" >保费费率</div>
                    <div field="insuranceFee" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">保费</div>
                    <div field="openBillDeliveryCharge" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">开单送货费</div>
                    <div field="agentDeliveryCharge" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">代理送货费</div>
                    <div field="deliveryChargeComment" width="140" headerAlign="center" align="left" allowSort="false">送货费备注</div>
                    <div field="tax" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">税金</div>
                    <div field="fuelSurcharge" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">燃油费</div>
                    <div field="collectionMoney" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">代收款</div>
                    <div field="otherCharges" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">其他费用</div>
                    <div field="otherChargesComment" width="140" headerAlign="center" align="center" allowSort="false">其他费用说明</div>
                    <div field="serviceCharge" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">业务费</div>
                    <div field="actualTransportCost" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">实收运费</div>

                    <div field="businessCostAllocationId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">是否分摊业务费</div>
                    <div field="businessCostAllocationTypeId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">业务费分摊类型</div>
                    <div field="businessCostComment" width="140" headerAlign="center" align="center" allowSort="false">业务费备注</div>

                    <div field="innerOperationCharge" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">内部操作费</div>
                    <div field="deliveryCustomerPaymentMethodId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">发货人付款方式</div>
                    <div field="deliveryCustomerPaymentAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">发货人付款金额</div>
                    <div field="receiveCustomerPaymentMethodId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">收货人付款方式</div>
                    <div field="receiveCustomerPaymentAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">收货人付款金额</div>
                    <div field="totalAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总金额</div>
                    <div field="actualAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">实收金额</div>
                    <div field="dropAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">调整金额(拉货)</div>

                    <div field="settlementAmount" width="200" headerAlign="center" align="right" allowSort="false" renderer="public_redBoldMoneyRenderer" summaryType="sum">
                        <span style="color: red;font-weight: bold">结算金额(实收金额+调整金额)</span>
                    </div>

                    <div field="shareCost" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">分摊成本</div>
                    <div field="shareCostComment" width="140" headerAlign="center" align="center" allowSort="false">分摊成本说明</div>
                    <div field="operatingCost" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">操作费</div>
                    <div field="grossProfit" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">毛利润</div>

                    <!--                    <div field="deliveryCustomerId" width="140" headerAlign="center" align="center" allowSort="true">发货人ID</div>-->
                    <div field="deliveryCustomerName" width="140" headerAlign="center" align="center" allowSort="true">发货人名称</div>
                    <div field="deliveryCustomerPhone" width="140" headerAlign="center" align="center" allowSort="true" renderer="commonDesensitization">发货人电话</div>
                    <div field="deliveryCustomerAddress" width="140" headerAlign="center" align="center" allowSort="true">发货人地址</div>

                    <!--                    <div field="deliveryCustomerContactId" width="140" headerAlign="center" align="center" allowSort="true">发货人联系人ID</div>-->
                    <div field="deliveryCustomerContactName" width="140" headerAlign="center" align="center" allowSort="true">发货人联系人名称</div>
                    <div field="deliveryCustomerContactPhone" width="140" headerAlign="center" align="center" allowSort="true" renderer="commonDesensitization">发货人联系人电话</div>

                    <div field="receiveCustomerName" width="140" headerAlign="center" align="center" allowSort="true">收货人名称</div>
                    <div field="receiveCustomerPhone" width="140" headerAlign="center" align="center" allowSort="true">收货人电话</div>
                    <div field="receiveCustomerAddress" width="140" headerAlign="center" align="center" allowSort="true">收货人地址</div>

                    <!--                    <div field="pickUpPointId" width="140" headerAlign="center" align="center" allowSort="true">提货点ID</div>-->
                    <div field="pickUpPointName" width="140" headerAlign="center" align="center" allowSort="true">提货点名称</div>
                    <div field="pickUpPointPhone" width="140" headerAlign="center" align="center" allowSort="true" renderer="commonDesensitization">提货点电话</div>
                    <div field="pickUpPointAddress" width="140" headerAlign="center" align="center" allowSort="true">提货点地址</div>
                    <div field="pickUpGoodsWayId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"sysDic"}' renderer="commonRender">提货方式</div>

                    <div field="signChooseId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"sysDic"}' renderer="commonRender">签收方式</div>
                    <div field="deliveryCustomerSalemanId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"sysUser"}' renderer="commonRender">发货客户业务员</div>
                    <div field="flightDate" width="140" headerAlign="center" align="center" allowSort="true" dateFormat="yyyy-MM-dd" renderer="ondayRenderer">班次日期</div>
                    <!--                    <div field="flightNo" width="140" headerAlign="center" align="center" allowSort="true">班次号ID</div>-->
                    <div field="flightName" width="140" headerAlign="center" align="center" allowSort="true">班次号名称</div>
                    <div field="airlinesId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"airlines"}' renderer="commonRender">航空公司</div>
                    <div field="planTakeOffTime" width="140" headerAlign="center" align="center" allowSort="true">计划出发时间</div>


                    <div field="attributionDepartmentId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"department"}' renderer="commonRender">归属部门</div>
                    <div field="transportSpeciesId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"sysDic"}' renderer="commonRender">运输种类</div>
                    <div field="transportWayId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"sysDic"}' renderer="commonRender">承运方式</div>
                    <div field="transportScopeId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"sysDic"}' renderer="commonRender">运输范围</div>
                    <div field="cityId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"city"}' renderer="commonRender">营业部所在城市</div>


                    <div field="printActualWeight" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">打单实际重量</div>
                    <div field="printChargeableWeight" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" >打单计费重量</div>
                    <div field="printWeightRate" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">打单重量费率</div>
                    <div field="printVolume" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">打单体积</div>
                    <div field="printVolumeRate" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" >打单体积费率</div>



<!--                    <div field="cashierId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysUser"}' renderer="commonRender">收银员</div>-->
                    <div field="openBillUserId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysUser"}' renderer="commonRender">开单人</div>
                    <div field="openBillDepartmentId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"department"}' renderer="commonRender">开单部门</div>
                    <div field="rollCallDepartmentId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"department"}' renderer="commonRender">点到部门</div>
                    <div field="comment" width="140" headerAlign="center" align="center" allowSort="false">备注</div>

                    <div field="billLoadStatusId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">配载状态</div>
                    <div field="businessCostStatusId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">业务费状态</div>
                    <div field="agentDeliveryChargeStatusId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">代理送货费状态</div>
                    <div field="arrearsStatusId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">分单欠款状态</div>
                    <div field="dropStatusId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">拉货状态</div>
                    <div field="accountCheckStatusId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">对账状态</div>
                    <div field="settlementStatusId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">结算状态</div>

                    <div field="cancelStatusId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">作废状态</div>

                    <div field="createTime" width="140" headerAlign="center" align="center" allowSort="false" dateFormat="yyyy-MM-dd HH:mm:ss" renderer="ondayRenderer">创建时间</div>
                    <div field="createUserId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysUser"}' renderer="commonRender">创建用户</div>
                    <div field="updateTime" width="140" headerAlign="center" align="center" allowSort="false" dateFormat="yyyy-MM-dd HH:mm:ss" renderer="ondayRenderer">更新时间</div>
                    <div field="updateUserId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysUser"}' renderer="commonRender">更新用户</div>

                </div>
            </div>
        </div>

        <!-- 子表  renderer="showMasterBillRender" -->
        <div id="detailDiv" style="display:none; margin-left: 50px">
            <div id="detailGrid" class="mini-datagrid" style="width:1400px;height:200px;"
                 url="${base}/pages/master_bill_manage/load/queryMasterBillByNativeBillId">
                <div property="columns">
                    <div field="masterBillId" width="100" headerAlign="center" align="center"  renderer="showMasterBillRender"  >主单号</div>
                    <div field="masterBillTypeId" width="70" headerAlign="center" align="center" data-options='{cacheName:"sysDic"}' renderer="commonRender">主单类型</div>
                    <div field="airlinesId" width="140" headerAlign="center" align="left" data-options='{cacheName:"airlines"}' renderer="commonRender">配载公司</div>
                    <div field="flightName" width="70" headerAlign="center" align="center" >班次名称</div>
                    <div field="flightDate" width="70" headerAlign="center" align="center" dateFormat="yyyy-MM-dd" renderer="ondayRenderer">班次日期</div>
                    <div field="nativeBillId" width="70" headerAlign="center" align="center" >分单号</div>
                    <div field="loadNumber" width="70" headerAlign="center" align="right" >配载分单数</div>
                    <div field="loadActualWeight" width="70" headerAlign="center" align="right" >配载分单实际重量</div>
                    <div field="loadChargeableWeight" width="70" headerAlign="center" align="right" >配载分单计费重量</div>
                    <div field="loadVolume" width="70" headerAlign="center" align="right" >配载分单体积</div>
                </div>
            </div>
        </div>


        <!-- 分单签收状态窗口 -->
        <div id="signStatusPanel" class="mini-window" title="分单签收" style="width:1000px;height:500px;"
             showMaxButton="true" showCollapseButton="false" showMinButton="true" showShadow="true"
             showToolbar="true" showFooter="true" showModal="true" allowResize="true" allowDrag="true">

            <div property="footer" style="padding:10px;text-align: right">
                <a  class="mini-button" iconCls="icon-ok" onclick="addSignStatus()">添加状态</a>
                <a  class="mini-button" iconCls="icon-close" onclick="public_onCancel('signStatusPanel')">关闭</a>
            </div>


            <div style="margin-top: 5px"></div>
            <span>分单签收状态列表:</span>
            <div style="margin-top: 5px"></div>

            <div id="signStatusDatagrid" class="mini-datagrid"
                 style="width: 100%; height: 200px;" idField="id"
                 showPager="false"  allowResize="true"
                 allowCellEdit="true" allowCellSelect="true"
                 editNextOnEnterKey="true"  editNextRowCell="true"
                 sortField="createTime"
                 sortOrder="desc" >
                <div property="columns">
                    <div type="indexcolumn" >序号</div>
                    <div field="signStatusId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysDic"}' renderer="commonRender">配载状态</div>
                    <div field="createTime" width="140" headerAlign="center" align="center" allowSort="false" dateFormat="yyyy-MM-dd HH:mm:ss" renderer="ondayRenderer">创建时间</div>
                    <div field="createUserId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"sysUser"}' renderer="commonRender">创建用户</div>
                    <div width="140" headerAlign="center" align="center" allowSort="false" renderer="opRenderer">操作</div>
                </div>
            </div>

            <div id="signStatusForm">
                <span>分单号:</span>
                <input id="nativeBillId" name="nativeBillId" emptyText="请输入分单号"  class="mini-textbox" required="true" enabled="false" requiredErrorText="分单号不能为空" />
                <span>签收状态:</span>
                <input id="signStatusId" name="signStatusId" class="mini-combobox" style="width:120px;" textField="name" valueField="id" emptyText="请选择..."
                       required="true" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择签收状态"/>
            </div>
        </div>


        <!-- 分单提货费用填写 -->
        <div id="billPickupDriverFeePanel" class="mini-window" title="提货费登记" style="width:300px;height:200px;"
             showMaxButton="true" showCollapseButton="false" showMinButton="true" showShadow="true"
             showToolbar="true" showFooter="true" showModal="true" allowResize="true" allowDrag="true">

            <div property="footer" style="padding:10px;text-align: right">
                <a  class="mini-button" iconCls="icon-save" onclick="fillPickupDriverFee()">保存</a>
                <a  class="mini-button" iconCls="icon-close" onclick="public_onCancel('billPickupDriverFeePanel')">关闭</a>
            </div>

            <div style="margin-top: 5px"></div>
            <span>提货费:</span><input id="pickupDriverFee"  name="pickupDriverFee"  vtype="int" value="0" emptyText="提货费"  class="mini-textbox" required="required" requiredErrorText="提货费不能为空" />
            <div style="margin-top: 5px"></div>
            <div style="margin-top: 5px"></div>
            <span>提货人:</span><input id="pickupDriverName"  name="pickupDriverName"  emptyText="提货人"  class="mini-textbox" required="required" requiredErrorText="提货人不能为空"/>

        </div>

        <!-- 分单日报打印 -->
        <div id="billDailyReportPrintPanel" class="mini-window" title="分单日报打印" style="width:1400px;height:700px;"
             showMaxButton="true" showCollapseButton="false" showMinButton="true" showShadow="true"
             showToolbar="true" showFooter="true" showModal="true" allowResize="true" allowDrag="true">

            <div property="footer" style="padding:10px;text-align: right">
                <span>选择打印机:</span>
                <select id="printerList">
                    <option></option>
                </select>
                <a  class="mini-button" iconCls="icon-ok" onclick="dailyReportPrint('1')">打印</a>
                <a  class="mini-button" iconCls="icon-ok" onclick="dailyReportPrint('2')">打印预览</a>
                <a  class="mini-button" iconCls="icon-ok" onclick="dailyReportPrint('3')">页面设置</a>
                <a  class="mini-button" iconCls="icon-close" onclick="public_onCancel('billDailyReportPrintPanel')">关闭</a>
            </div>
            <!-- 打印内容显示区 -->
            <div id="tableDataId"></div>

        </div>




        <script type="text/javascript">
            mini.parse();

            let keyAttributionDepartmentId = mini.get("keyAttributionDepartmentId");
            let keyTransportSpeciesId = mini.get("keyTransportSpeciesId");
            let keyTransportWayId = mini.get("keyTransportWayId");
            let keyPickUpGoodsWayId = mini.get("keyPickUpGoodsWayId");
            let keySignChooseId = mini.get("keySignChooseId");
            let keyPickUpPointId = mini.get("keyPickUpPointId");
            let keyBillLoadStatusId = mini.get("keyBillLoadStatusId");
            let keyDropStatusId = mini.get("keyDropStatusId");
            let keySettlementStatusId = mini.get("keySettlementStatusId");
            let keyCancelStatusId = mini.get("keyCancelStatusId");
            let keyAccountCheckStatusId = mini.get("keyAccountCheckStatusId");


            let keyGoodsName = mini.get("keyGoodsName");
            let keyAirportId = mini.get("keyAirportId");
            let keyDestCityId = mini.get("keyDestCityId");
            let keyFlightName = mini.get("keyFlightName");

            let signStatusId = mini.get("signStatusId");
            let nativeBillId = mini.get("nativeBillId");

            let grid = mini.get("datagrid1");

            // 明细 grid块
            let detailDiv = document.getElementById("detailDiv");

            let detailGrid = mini.get("detailGrid");

            let signStatusDatagrid = mini.get("signStatusDatagrid");

            $(function () {

                let keyAttributionDepartmentIdJsonData = commonRenderDropList("department");
                keyAttributionDepartmentId.loadList(keyAttributionDepartmentIdJsonData,"id","pid");

                // 运输种类下拉列表
                let transportSpeciesIdJsonData=commonRenderSysDicDropListByKey("sysDic","XT_DIC_TRANSPORT_SPECIES");
                keyTransportSpeciesId.load(transportSpeciesIdJsonData);

                // 承运方式下拉列表
                let transportWayIdJsonData=commonRenderSysDicDropListByKey("sysDic","XT_DIC_TRANSPORT_WAY");
                keyTransportWayId.load(transportWayIdJsonData);

                // 提货方式下拉列表
                let pickUpGoodsWayIdJsonData=commonRenderSysDicDropListByKey("sysDic","XT_DIC_PICK_UP_GOODS_WAY");
                keyPickUpGoodsWayId.load(pickUpGoodsWayIdJsonData);

                // 签收方式下拉列表
                let signChooseIdJsonData=commonRenderSysDicDropListByKey("sysDic","XT_DIC_SIGN_CHOOSE");
                keySignChooseId.load(signChooseIdJsonData);

                // 配载状态下拉列表
                let keyBillLoadStatusIdJsonData = commonRenderSysDicDropListByKey("sysDic","XT_DIC_BILL_LOAD_STATUS");
                keyBillLoadStatusId.load(keyBillLoadStatusIdJsonData);

                // 拉货状态
                let keyDropStatusIdJsonDate  = commonRenderSysDicDropListByKey("sysDic","XT_DIC_PULL_STATUS");
                keyDropStatusId.load(keyDropStatusIdJsonDate);

                // 对账状态
                let keyAccountCheckStatusIdJsonDate  = commonRenderSysDicDropListByKey("sysDic","XT_DIC_ACCOUNT_CHECK_STATUS");
                keyAccountCheckStatusId.load(keyAccountCheckStatusIdJsonDate);

                // 结算状态
                let keySettlementStatusIdJsonDate  = commonRenderSysDicDropListByKey("sysDic","XT_DIC_SETTLEMENT_STATUS");
                keySettlementStatusId.load(keySettlementStatusIdJsonDate);

                // 作废状态
                let keyCancelStatusIdJsonDate  = commonRenderSysDicDropListByKey("sysDic","XT_DIC_CANCEL_STATUS");
                keyCancelStatusId.load(keyCancelStatusIdJsonDate);

                // 签收状态 XT_DIC_SIGN_STATUS
                let signStatusIdJsonData = commonRenderSysDicDropListByKey("sysDic","XT_DIC_SIGN_STATUS");
                signStatusId.load(signStatusIdJsonData);


                // 加载机场
                let keyAirportIdJsonData = commonRenderDropList("airport");
                keyAirportId.load(keyAirportIdJsonData);


                // 加载目的城市下拉列表
                let keyDestCityIdJsonData=commonRenderDropList("city");
                keyDestCityId.loadList(keyDestCityIdJsonData,"id","pid");


                /**
                 * let keyGoodsName = mini.get("keyGoodsName");
                 let keyAirportId = mini.get("keyAirportId");
                 let keyDestCityId = mini.get("keyDestCityId");
                 */

                // 加载列表数据
                grid.load();
            });

            function clearSearch(){
                let form = new mini.Form("#queryForm");
                form.clear();
            }

            /**
             * 根据查询条件查询分单
             */
            function searchBill(){
                let form = new mini.Form("#queryForm");
                let data = form.getData(true);
                grid.load(data);
            }


            function showNativeBillRender(e){
                let nativeBillId = e.value;
                let htmlStr = "<a href='javascript:void(0);' onclick='showViewNativeBill(\""+ nativeBillId +"\")'>" + nativeBillId + "</a>";
                return htmlStr;
            }

            function showViewNativeBill(nativeBillId){
                let tabUrl="${base}/pages/native_bill_manage/showUpdateBill?opType=view&id=" + nativeBillId;
                parent.window.addTabToMainPage("分单查看","分单查看",tabUrl);
            }


            /**
             * 根据选择的分单进行分单编辑
             */
            function editBillShow(){
                let billObjs = grid.getSelecteds();
                if(billObjs.length>0){
                    if(billObjs.length==1){
                        let tabUrl="${base}/pages/native_bill_manage/showUpdateBill?opType=update&id=" + billObjs[0].id;
                        parent.window.addTabToMainPage("分单编辑","分单编辑",tabUrl);
                    }
                    else{
                        mini.alert("编辑时请选择一行！");
                    }
                }
                else{
                    mini.alert("请选择需要编辑的对象！");
                }
            }

            /**
             *
             * 根据选择的分单作废分单
             *
             * 410,0,作废状态,作废状态,XT_DIC_CANCEL_STATUS
             * 411,410,未作废,未作废,
             * 412,410,已作废,已作废,

             * 350,0,分单配载状态,分单配载状态,XT_DIC_BILL_LOAD_STATUS
             * NO_LOAD(351, "未配载", "未配载"),
             * PART_LOAD(352, "部分配载", "部分配载"),
             * ALL_LOAD(353, "全部配载", "全部配载");

             * 320,0,结算状态,结算状态,XT_DIC_SETTLEMENT_STATUS
             * 321,320,未结算,未结算,""
             * 322,320,已结算,已结算,""
             *
             *
             * 430,0,分单主单对账状态,分单主单对账状态,XT_DIC_ACCOUNT_CHECK_STATUS
             * 431,430,未对账,未对账,
             * 432,430,已对账,已对账,
             */

            let cancelStatus = {noCancel:411, canceled:412};

            let loadStatus = {noLoad:351, partLoad:352, allLoad:353};

            let settlementStatus = {uncleared:321, cleared:322};

            let accountCheckStatus = {noCheck:431, checked:432};

            function cancelBill(){
                let billObjs = grid.getSelecteds();

                if(billObjs.length==0){
                    showAlert("请选择需要作废的分单!");
                    return;
                }

                let cancelBillIds = "";
                let cancelFalg = false;
                // 判断选择的分单的配载情况
                for(let obj of billObjs){
                    if(obj.billLoadStatusId == loadStatus.partLoad || obj.billLoadStatusId == loadStatus.allLoad || obj.settlementStatusId == settlementStatus.cleared || obj.accountCheckStatusId == accountCheckStatus.checked){
                        cancelFalg = true;
                        break;
                    }
                    cancelBillIds += "'" + obj.id + "',";
                }

                if(cancelFalg){
                    showAlert("选择作废的分中包含全部配载或部分配载或已对账或已结算完成的分单，不能进行作废操作!")
                    return;
                }

                // 现在的cancelBillIds中包含的全部是未配载的分单位，可以进行作废操作
                cancelBillIds = cancelBillIds.substring(0,cancelBillIds.length-1);

                mini.confirm("确定作废已经选择的分单？", "分单作废",
                    function (action) {
                        if (action == "ok") {
                            // String statusFieldName, Long statusId, String billIds,  cacel_status_id
                            let ret = public_getServerData("${base}/pages/native_bill_manage/cancelNativeBill",{billIds:cancelBillIds});
                            showAlert(ret.message,function (){
                                if(ret.ok){
                                    grid.reload();
                                }
                            });
                        }
                    }
                );
            }

            /**
             * 分单删除条件
             1.如果分单没有被配载，则分单可以直接删除
             2.如果分单被部分配载或全部配载则不能删除
             */
            function deleteBill(){
                let billObjs = grid.getSelecteds();

                if(billObjs.length==0){
                    showAlert("请选择需要删除的分单!");
                    return;
                }

                // 判断选择的分单配载情况
                let canDeleteBillIds = "";
                let canNotDeleteBillIds = "";
                for(let obj of billObjs){
                    // 分单删除直接判断分单有没有主单号，如果没有，则可以删除，否则不可以删除
                    if(public_isEmpty(obj.billLoadMasterBillIds)){
                        canDeleteBillIds += obj.id + ",";
                    }
                    else{
                        canNotDeleteBillIds += obj.id + ",";
                    }


                    // if(obj.billLoadStatusId == loadStatus.partLoad || obj.billLoadStatusId == loadStatus.allLoad || obj.settlementStatusId == settlementStatus.cleared || obj.accountCheckStatusId == accountCheckStatus.checked){
                    //     console.log(obj);
                    //     console.log("-----------obj.billLoadStatusId-------------");
                    //     console.log(obj.billLoadStatusId);
                    //     console.log("-----------obj.settlementStatusId-------------");
                    //     console.log(obj.settlementStatusId);
                    //     console.log("-----------obj.accountCheckStatusId-------------");
                    //     console.log(obj.accountCheckStatusId);
                    //
                    //     console.log("-----------loadStatus-------------");
                    //     console.log(loadStatus);
                    //     console.log("-----------settlementStatus-------------");
                    //     console.log(settlementStatus);
                    //     console.log("-----------accountCheckStatus-------------");
                    //     console.log(accountCheckStatus);
                    //
                    //
                    //     canNotDeleteBillIds += obj.id + ",";
                    // }
                    // else{
                    //     canDeleteBillIds += obj.id + ",";
                    // }
                }


                if(canNotDeleteBillIds.length>0){
                    canNotDeleteBillIds = canNotDeleteBillIds.substring(0,canNotDeleteBillIds.length-1);
                    showAlert("选择的分单【" + canNotDeleteBillIds + "】,由于已配载、已对账或已结算,不能进行删除操作!");
                    return;
                }

                // 可以删除的分单号
                if(canDeleteBillIds.length==0){
                    return;
                }

                canDeleteBillIds = canDeleteBillIds.substring(0,canDeleteBillIds.length-1);

                mini.confirm("确定删除已经选择【" + canDeleteBillIds + "】分单？", "分单删除",
                    function (action) {
                        if (action == "ok") {
                            // String statusFieldName, Long statusId, String billIds,  cacel_status_id
                            let ret = public_getServerData("${base}/pages/native_bill_manage/deleteNativeBillByBillIds",{billIds:canDeleteBillIds});
                            showAlert(ret.message,function (){
                                if(ret.ok){
                                    grid.reload();
                                }
                            });
                        }
                    }
                );
            }

            /**
             * 签收状态的添加必须是一个一个分单添加,不同意做成一块添加
             */
            function showSignStatusPanel(){
                let selectItems = grid.getSelecteds();
                if(selectItems.length==0){
                    showAlert("请选择要改变签收状态的分单");
                    return;
                }

                if(selectItems.length>1){
                    showAlert("修改分单签收状态时不能同时选择多条分单!");
                    return;
                }

                loadStatusData(selectItems[0].id);

                nativeBillId.setValue(selectItems[0].id);

                public_showModelAtPos("signStatusPanel", "center", "middle");
            }

            function loadStatusData(billId){
                let signStatusUrl = "${base}/pages/native_bill_manage/sign_choose_detail/queryBillSignStatus?billId=" + billId;
                signStatusDatagrid.setUrl(signStatusUrl);
                signStatusDatagrid.load();
            }


            function addSignStatus(){
                let signStatusForm = new mini.Form("#signStatusForm");
                signStatusForm.validate();
                if (signStatusForm.isValid() == false) {
                    return;
                }

                let nativeBillIdValue = nativeBillId.getValue();
                let signStatusIdValue = signStatusId.getValue();
                let isExist = false;
                // 检测是否有重复
                let statusList = signStatusDatagrid.data;
                if(!public_isEmpty(statusList) && statusList.length>0){
                    for(let obj of statusList){
                        if(obj.signStatusId == signStatusIdValue){
                            isExist=true;
                            break;
                        }
                    }
                    if(isExist){
                        showAlert("添加的状态已经在列表中存在，不能重复添加!");
                        return;
                    }
                }

                let signStatusFormData = signStatusForm.getData(true);

                // 给出确认提示框
                mini.confirm("确定为分单【" + nativeBillIdValue + "】添加签收状态?", "签收状态提示",
                    function (action) {
                        if (action == "ok") {
                            let ret = public_getServerData("${base}/pages/native_bill_manage/sign_choose_detail/addBillSignStatus",signStatusFormData);
                            showAlert(ret.message,function (){
                                if(ret.ok){
                                    signStatusId.setValue();
                                    loadStatusData(nativeBillIdValue);
                                }
                            });
                        }
                    }
                );
            }

            function opRenderer(e){
                let idValue = e.record.id;
                let btnHtml = "<a class='mini-button' onclick='deleteStatus(\"" + idValue + "\")' style='width: 50px'>删除</a>"
                return btnHtml;
            }

            function deleteStatus(idValue){
                let nativeBillIdValue = nativeBillId.getValue();
                // 给出确认提示框
                mini.confirm("确定删除分单【" + nativeBillIdValue + "】签收状态?", "签收状态提示",
                    function (action) {
                        if (action == "ok") {
                            let ret = public_getServerData("${base}/pages/native_bill_manage/sign_choose_detail/deleteBillSignStatus?id="+idValue);
                            showAlert(ret.message,function (){
                                if(ret.ok){
                                    signStatusId.setValue();
                                    loadStatusData(nativeBillIdValue);
                                }
                            });
                        }
                    }
                );
            }

            /**
             * 加载明细
             */
            function onShowRowDetail(e){
                let grid = e.sender;
                let row = e.record;

                let td = grid.getRowDetailCellEl(row);
                td.appendChild(detailDiv);

                detailDiv.style.display = "block";

                detailGrid.load({nativeBillId: row.id});

            }


            /**
             * 主单号链接渲染
             */
            function showMasterBillRender(e) {
                let masterBillId = e.record.masterBillId;
                let masterBillTypeId  = e.record.masterBillTypeId;

                let htmlStr = '<a href="javascript:void(0);" rel="external nofllow" rel="external nofollow" onclick="openMasterBillEditPage(\'' + masterBillId + '\',\''+ masterBillTypeId +'\')">' + masterBillId + '</a>';

                return htmlStr;
            }

            /**
             * 260,0,主单类型,主单类型,XT_DIC_MASTER_BILL_TYPE
             261,260,航空主单,航空主单,""
             262,260,汽运主单,汽运主单,""
             */
            let masterBillType={air:261,auto:262}

            function openMasterBillEditPage(masterBillId,masterBillTypeId) {
                // 根据类型打开相应的编辑页面，在编辑页面上做些处理，把保存按钮给隐藏了
                let tabUrl;
                let title;
                if(masterBillTypeId==masterBillType.air){
                    title = "空运主单";
                    tabUrl="${base}/pages/master_bill_manage/flight/showUpdateMasterBill?opType=view&id=" + masterBillId;
                }
                else{
                    title = "汽运主单";
                    tabUrl=tabUrl="${base}/pages/master_bill_manage/auto/showUpdateMasterBill?opType=view&id=" + masterBillId;
                }

                parent.window.addTabToMainPage(title,title,tabUrl);
            }


            let pickupDriverFeeId;
            function showFillPickupDriverFee(){
                let selectedItem = grid.getSelecteds();
                if(selectedItem.length == 0){
                    showAlert("没有选择需要添加提货费的分单!");
                    return;
                }

                if(selectedItem.length > 1){
                    showAlert("填写分单提货费不支持多分单批量填写!");
                    return;
                }

                pickupDriverFeeId = selectedItem[0].id;

                console.log(pickupDriverFeeId);

                public_showModelAtPos("billPickupDriverFeePanel", "center", "middle");
            }


            function fillPickupDriverFee(){
                // pickupDriverFee  pickupDriverName
                let pickupDriverFee = mini.get("pickupDriverFee").getValue();
                let pickupDriverName = mini.get("pickupDriverName").getValue();

                if(!public_isNumber(pickupDriverFee)){
                    showAlert("提货费是非数值!");
                    return;
                }

                if(!public_isEmpty(pickupDriverName)){
                    showAlert("提货司机名称不能为空!");
                    return;
                }

                let billObj = {};
                billObj.id = pickupDriverFeeId;
                billObj.pickupDriverFee = pickupDriverFee;
                billObj.pickupDriverName = pickupDriverName;

                let ret = public_getServerData("${base}/pages/native_bill_manage/savePickupDriverFee",billObj);
                showAlert(ret.message,function (){
                    if(ret.ok){
                        grid.reload();
                    }
                });
            }



            /**
             * 设置底部统计样式
             * @param e
             */
            function summaryRight(e){
                e.cellStyle="text-align:right;color:red;font-size:18px;font-weight:bold";
            }




            let dailyReportTable = "";
            /**
             * 显示打印日报面板，同时构建需要打印的日报对象
             */
            function showDailyReportPrintPanel(){
                let form = new mini.Form("#queryForm");
                let data = form.getData(true);

                let ret = public_getServerData("${base}/pages/native_bill_manage/dailyReport",data);

                /**
                 * map.put("printOne",printOne);
                 map.put("printDepartment",printDepartment);
                 map.put("printDate",printDate);
                 map.put("printData",bNativeBillPojoList);
                 */

                if(!ret.ok){
                    showAlert(ret.message);
                    return;
                }

                let printData = ret.data.printData;
                let printOne = ret.data.printOne;
                let printDepartment = ret.data.printDepartment;
                let printDate = ret.data.printDate;
                if(public_isEmpty(printData) || printData.length ==0){
                    showAlert("操作员【" + printOne + "】无对应的开单日报!")
                    return;
                }


                // 构建打印对象Table对象
                /**
                 * 用超文本增加一个表格打印项，设定该表格在每个纸张内的位置和区域大小。
                 * 打印时只输出首个页面元素table的显示内容，
                 * 当table内包含thead或tfoot时，一旦表格被分页，则每个打印页都输出表头(thead)或表尾(tfoot)
                 * @type {string}
                 */
                let tableHtml ="<table border='1' class='border1 tab1' cellspacing='0' style='width: 98%;font-size: 9pt;border-collapse: collapse' >";
                tableHtml += "<caption><span style='font-size: 15pt;font-family: 黑体;font-weight: bold'>" + printDepartment + "分单销售日报</span></caption>";
                let tableHeader = "<thead>";
                tableHeader += "<tr><td   colspan='13' style='text-align: right;'><span style='margin-right: 10px'>打印日期:" + printDate + "</span><span>打印人:" + printOne + "</span></td></tr>"
                tableHeader += "<tr>";
                tableHeader += "<td class='border1'>" + "序号" + "</td>";
                tableHeader += "<td class='border1'>" + "分单号" + "</td>";
                tableHeader += "<td class='border1'>" + "目的站" + "</td>";
                tableHeader += "<td class='border1'>" + "发货人付款方式" + "</td>";
                tableHeader += "<td class='border1'>" + "付款金额" + "</td>";
                tableHeader += "<td class='border1'>" + "收货人付款方式" + "</td>";
                tableHeader += "<td class='border1'>" + "付款金额" + "</td>";
                tableHeader += "<td class='border1'>" + "业务费" + "</td>";
                tableHeader += "<td class='border1'>" + "代收货款" + "</td>";
                tableHeader += "<td class='border1'>" + "分单运费" + "</td>";
                tableHeader += "<td class='border1'>" + "实收金额" + "</td>";
                tableHeader += "<td class='border1'>" + "发货人" + "</td>";
                tableHeader += "<td class='border1'>" + "开单日期" + "</td>";
                tableHeader += "</tr>";
                tableHeader += "</thead>";

                // 定义各页行数 首页由于需要输出标题，所以就输出35行，其他页输出40行
                let pageRows = {firstPage:15,otherPage:20};

                // 分页标志
                let divPage = "<tr class='PageNext'><td colspan='13' class='PageNext'></td></tr>";

                let tableBody="<tbody>";
                let isFirstPage = true; // 是否首页
                let perPageRows = 0; // 每页行数
                for(let rowIndex = 0; rowIndex<printData.length; rowIndex++){
                    // 行数自增
                    perPageRows++;
                    // 获取行对象
                    let printObj = printData[rowIndex];
                    tableBody += "<tr>";
                    tableBody += "<td  class='border1'>" + (rowIndex+1) + "</td>";// 序号
                    tableBody += "<td  class='border1'>" + printObj.id + "</td>";//分单号
                    tableBody += "<td  class='border1'>" + commonRendderNameByKeyAndId("city",printObj.destCityId) + "</td>"; // 目的站
                    let deliveryCustomerPaymentMethodIdName = commonRendderNameByKeyAndId("sysDic",printObj.deliveryCustomerPaymentMethodId);
                    if(public_isEmpty(deliveryCustomerPaymentMethodIdName) || deliveryCustomerPaymentMethodIdName == ""){
                        deliveryCustomerPaymentMethodIdName = "";
                    }
                    tableBody += "<td class='border1'>" + deliveryCustomerPaymentMethodIdName + "</td>"; // 发货人付款方式

                    tableBody += "<td class='border1'>" + printObj.deliveryCustomerPaymentAmount + "</td>"; // 付款金额

                    let receiveCustomerPaymentMethodIdName = commonRendderNameByKeyAndId("sysDic",printObj.receiveCustomerPaymentMethodId);
                    if(public_isEmpty(receiveCustomerPaymentMethodIdName) || receiveCustomerPaymentMethodIdName == ""){
                        receiveCustomerPaymentMethodIdName="";
                    }
                    tableBody += "<td class='border1'>" + receiveCustomerPaymentMethodIdName + "</td>"; //收货人付款方式
                    tableBody += "<td class='border1'>" + printObj.receiveCustomerPaymentAmount + "</td>"; // 付款金额
                    tableBody += "<td class='border1'>" + printObj.serviceCharge + "</td>"; // 业务费
                    tableBody += "<td class='border1'>" + printObj.collectionMoney + "</td>"; // 代收货款
                    tableBody += "<td class='border1'>" + printObj.transportCost + "</td>"; // 分单运费
                    tableBody += "<td class='border1'>" + printObj.actualAmount + "</td>"; // 实收金额
                    tableBody += "<td class='border1'>" + printObj.deliveryCustomerName + "</td>"; // 发货人
                    tableBody += "<td class='border1'>" + public_cstDataConvert(printObj.openBillDate) + "</td>";  //开单日期
                    tableBody += "</tr>";

                    // if(isFirstPage){
                    //     if(perPageRows == pageRows.firstPage){
                    //         // perPageRows=0;
                    //         // isFirstPage=false;
                    //         // // 分页标志e
                    //         // tableBody += divPage;
                    //         tableBody += "<tfoot></tfoot>";
                    //     }
                    // }
                    // else{
                    //     if(perPageRows == pageRows.otherPage){
                    //         // perPageRows=0;
                    //         // isFirstPage=false;
                    //         // // 分页标志e
                    //         // tableBody += divPage;
                    //         tableBody += "<tfoot></tfoot>";
                    //     }
                    // }
                }
                tableBody += "</tbody>";

                tableBody += "<tfoot></tfoot>";

                tableHtml += tableHeader;
                tableHtml += tableBody;
                tableHtml += "</table>";

                // 表格对象构建完成，显示一个弹出面板，用于选择打印机
                dailyReportTable = tableHtml;


                let ele = $('#tableDataId');
                ele.html(tableHtml);

                // 加载打印机列表
                getPrinterlist("printerList");

                public_showModelAtPos("billDailyReportPrintPanel", "center", "middle");

            }


            /**
             * 根据ID加载打印机列表
             */
            function getPrinterlist(printerId) {
                let printList = $("#"+printerId); //打印机下拉列表
                // 清空下拉列表
                printList.empty();
                printList.prepend("<option value='-1'>请选择</option>");

                let lodop = getLodop($("#LODOP_OB"),$("#LODOP_EM"));

                let printerAccount = lodop.GET_PRINTER_COUNT();

                for (let i = 0; i < printerAccount; i++) {
                    let printerIndex = i.toString();
                    let printerName = lodop.GET_PRINTER_NAME(i);
                    printList.append("<option value='" + printerIndex + "'>" + printerName + "</option>");
                }
            }


            function dailyReportPrint(opType) {

                let selectedPrinterName = $("#printerList").find("option:selected").text();;
                if(public_isEmpty(selectedPrinterName) || selectedPrinterName=="请选择"){
                    showAlert("请选择指定打印机!");
                    return;
                }

                // 下面可以打印了
                // 获取打印对象
                let LODOP = getLodop($("#LODOP"), $("#LODOP_EM"));
                LODOP.PRINT_INIT("分单日报打印");
                LODOP.SET_PRINT_PAGESIZE(2, "0", "0", "A4"); //设置纸张高度


                // 头部表格
                // LODOP.ADD_PRINT_TABLE("0mm","2mm","100%","100%",dailyReportTopTable);
                LODOP.ADD_PRINT_TABLE("2mm","2mm","100%","100%",dailyReportTable);
                // 分单表格
                //LODOP.ADD_PRINT_TABLE("15mm","2mm","100%","100%",dailyReportTable);

                if (opType == "1") {
                    LODOP.SET_PRINTER_INDEXA(selectedPrinterName)
                    LODOP.PRINT(); //直接打印
                }else if (opType == "2") {
                    LODOP.SET_PRINTER_INDEXA(selectedPrinterName)
                    LODOP.PREVIEW(); //打印预览
                }else if (opType == "3") {
                    LODOP.PRINT_SETUP(); //打印维护
                }
            }

        </script>
    </body>
</html>